/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;
using VSLangProj80;
using Microsoft.VisualStudio.VCProjectEngine;

namespace DaveSexton.DocProject
{
	internal static class VCProjectFactory
	{
		#region Methods
		/// <param name="canUseCache">Indicates whether the static cache may be searched for <paramref name="project"/> if it's a valid DocProject.
		/// Note that the cache isn't used for other project types (this parameter will be ignored in all other cases).</param>
		public static VCDocProject CreateVCDocProject(VSProject2 project, bool canUseCache)
		{
			VCProject vcProject = project as VCProject;

			if (vcProject == null)
				return null;
			else if (canUseCache)
			{
				VCDocProject cachedProject = DocProjectEnvironment.GetDocProject(vcProject) as VCDocProject;

				if (cachedProject != null)
					return cachedProject;
			}
			
			return new VCDocProject(vcProject);
		}

		public static VCAnyProject CreateVCAnyProject(VSProject2 project)
		{
			VCProject vcProject = project as VCProject;

			return (vcProject != null) ? new VCAnyProject(vcProject) : null;
		}

		public static VCSourceProject CreateVCSourceProject(Project project)
		{
			VCProject vcProject = project.Object as VCProject;

			return (vcProject != null) ? new VCSourceProject(vcProject) : null;
		}
		#endregion
	}
}
